-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix subsetEquality: same referenced object on same level node of tree is regarded as circular reference #9322
Fix subsetEquality: same referenced object on same level node of tree is regarded as circular reference #9322
Conversation
Codecov Report
@@ Coverage Diff @@
## master #9322 +/- ##
==========================================
+ Coverage 64.76% 64.99% +0.23%
==========================================
Files 280 278 -2
Lines 11985 11913 -72
Branches 2956 2935 -21
==========================================
- Hits 7762 7743 -19
+ Misses 3591 3539 -52
+ Partials 632 631 -1
Continue to review full report at Codecov.
|
Thanks! This change seems reasonable to me, but I'm not too familiar with this part of the code base. Mind updating the changelog as well? |
… is regarded as circular reference
54a05f5
to
7a27e77
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks a lot!
You're welcome. Thanks for a very swift response ! |
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Summary
This fixes #9089
This bug is introduced by this PR #8687
So basically, there is a flaw on the circular reference logic within a function called
subsetEquality
.The logic is that, to avoid circular reference, it stores the references of nodes that it has been through within one singleton variable
seenReferences
. Whenever we have seen the same node (using the reference), we skip the subset equality checking (which is done recursively) and do deep equality checking instead.The implication is that nodes within the same level of tree will use the same reference
seenReferences
. It's a problem because then it will cause an invalid handling on this case :On current logic, above case is considered circular referenced which isn't supposed to be. It will result in incorrect handling because circular reference does not check for subset equality and only check for plain equality instead. It makes sense for circular referenced object but not for normal object.
What we should do is to keep the
seenReferences
only for parent node and its children. The solution is quite simple, we only need to remove the reference immediately after the recursive function is done called for all of a node's children.Test plan
I have added one test case using example above which would fail previously.
After the fix, now it succeeds.